<?php

namespace App\Http\Resources\Apps;

use Illuminate\Http\Resources\Json\JsonResource;

class CouponResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'    => $this['id'],
            'name'  => $this['coupon']['name'],
            'coupon_value' => $this['coupon']['value'],
            'value' => $this['value'],
            'start' => $this['created_at'],
            'end'   => date('Y-m-d H:i:s',strtotime($this['created_at'].' +'.$this['coupon']['expire'].' day'))
        ];
    }
}
